<?php
/*

Version 0.1
SEMF - Web Desiging Framework for Sport Event Managment
Copyright (C) 2006, SEMF Developers

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
/**
	list_tables.php
	1. just list currently available tables
*/
	$module_name = $_GET['module'];
	$project_home= $_GET['project_home'];
	
	$SEMF_ROOT = "../../";
	
	// Define that we are returning XML content & not to cache:
	header('Content-Type: text/xml');
	header('Cache-control: no-cache');

	//echo $module_name;
	$module_xml = $SEMF_ROOT.$project_home.$module_name.'/module.xml';


?>
<div style="padding:20px ;">
<div style="padding:5px;">
<img src="../lib/images/addentitylightblue.png" width="71" height="25" onmouseover="javascript:changeImage(this,'addentityblack.png');" onmouseout="javascript:changeImage(this,'addentitylightblue.png');" onmousedown="javascript:changeImage(this,'addentitygreen.png');" onclick="javascript:addTableMode('<?php echo $module_name ?>','<?php echo $project_home ?>');"/>
</div>
<?php
$table_id = 0;
if (file_exists($module_xml)) {
	$doc = new DOMDocument();
	$doc->load($module_xml);
	$table_list = $doc-> getElementsByTagName('table');
?>
<style type="text/css">
<!--
.style_table {
	color: #003399;
	font-weight: bold;
	font-family: Geneva, Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-style: italic;
	background-image:'../lib/images/menuidle2.png' ;
	background-repeat:repeat-x;
}
-->
</style>
<table id="module_table" width="550" cellpadding="0" cellspacing="2" bgcolor="#000066" style="margin:10px">
  <?php
	foreach ( $table_list as $table )
	{
		if($table->getAttribute('interface') == 'yes'){
			$table_id++;
			continue;
		}
		$table_name = $table-> getAttribute('name');
		$color_code=($table_id%2==0)?"#C9D6F5":"#DEE2FE";


echo '<tr class="style_table" style="background-image:url(../lib/images/menuidle2.png);" onmouseover="javacript:setBg(this,\'activemenu.png\');"  onmouseout="javascript:setBg(this,\'menuidle2.png\');" >
<td width="20%" >'.$table_name.'</td><td width="20%"><img width="71" height="25" src="../lib/images/renamelightblue.png" onmouseover="javascript:changeImage(this,\'renameblue.png\');" onmouseout="javascript:changeImage(this,\'renamelightblue.png\');" onmousedown="javascript:changeImage(this,\'renamegreen.png\');" align="absmiddle" title="Rename Entity" onclick="javascript:editTableMode(\''.$table_name.'\',\''.$table_id.'\',\''.$module_name.'\',\''.$project_home.'\');"/></td>
<td width="20%" ><img width="71" height="25" src="../lib/images/deletelightblue.png" onmouseover="javascript:changeImage(this,\'deletered.png\');" onmouseout="javascript:changeImage(this,\'deletelightblue.png\');" onmousedown="javascript:changeImage(this,\'deletegreen.png\');"  align="absmiddle" title="Delete entity" onclick="javascript:deleteTable(\''.$table_id.'\',\''.$module_name.'\',\''.$project_home.'\');" /></td>
<td width="20%" >
<img src="../lib/images/editattributelightblue.png" onmouseover="javascript:changeImage(this,\'editattributeblack.png\');" onmouseout="javascript:changeImage(this,\'editattributelightblue.png\');" onmousedown="javascript:changeImage(this,\'editattributegreen.png\');" onclick="javascript:manageFields(\''.$table_name.'\',\''.$table_id.'\',\''.$module_name.'\',\''.$project_home.'\');" /></td>
<td width="20%" >
<img src="../lib/images/inheritlightblue.png" onmouseover="javascript:changeImage(this,\'inheritblack.png\');" onmouseout="javascript:changeImage(this,\'inheritlightblue.png\');" onmousedown="javascript:changeImage(this,\'inheritgreen.png\');" onclick="javascript:editInheritance(\''.$table_name.'\',\''.$table_id.'\',\''.$module_name.'\',\''.$project_home.'\');" /></td>
</tr>';
		
		$table_id ++;
	}
}
?>
</table>
<?php
if( $table_id == 0 )
{
?>
<div id="notables" style="color:#990000;  margin:10px; "> <i>There are no tables. To add a new table<b> Click</b> add new</i> </div>
<?php
}
?>

</div>